package com.itbaizhan.mybatispluslearn.method;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;
import org.springframework.stereotype.Component;


public class DeleteAll extends AbstractMethod {
    public DeleteAll(String methodName) {
        super(methodName);
    }

    @Override
    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
        //定义sql语句
        String sql = "delete from " + tableInfo.getTableName();
        //定义方法名
        String method = "deleteAll";
        //构建SqlSource，将语句传递到数据库
        SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration,sql,modelClass);

        return this.addDeleteMappedStatement(mapperClass,method,sqlSource);
    }
}
